package cm367;

import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;




public class FacilityValidator  implements ActionListener{

	@Override
	public void processAction(ActionEvent event) throws AbortProcessingException {
		FacesContext context = FacesContext.getCurrentInstance();
		Application app = context.getApplication();
		facilities fac = app.evaluateExpressionGet(context, "#{facilities}", facilities.class);
			if (!fac.isValid()){
				context.addMessage("e:c", new FacesMessage(
						FacesMessage.SEVERITY_ERROR,
						"Formula accept : [piece], [unitprice]",
						null));
				throw new AbortProcessingException();
			}
		
	}


}
